package com.zhongyu.scheduler.consumer.service.impl;

import com.zhongyu.comm.pojo.Scheduler;
import com.zhongyu.scheduler.consumer.client.SchedulerClient;
import com.zhongyu.scheduler.consumer.service.SchedulerService;
import com.zhongyu.scheduler.consumer.vo.SchedulerVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service("schedulerService")
public class SchedulerServiceImpl implements SchedulerService {
    @Resource
    private SchedulerClient schedulerClient;
    @Override
    public List<SchedulerVo> createOrder(Integer itemId) {
        List<Scheduler> list=schedulerClient.findById(itemId);
     return list.stream().map(scheduler -> {
            SchedulerVo schedulerVo=new SchedulerVo();
            BeanUtils.copyProperties(scheduler,schedulerVo);
            return schedulerVo;
        }).collect(Collectors.toList());
    }
}
